﻿using Microsoft.AspNetCore.Mvc;

namespace Magic.Web.Entry;

/// <summary>
/// 管理员服务
/// </summary>
public class SysUserController: BaseController
{
    private readonly ISysUserService _adminService;
    public SysUserController(ISysUserService adminService)
    {
        _adminService = adminService;
    }
    /// <summary>
    /// 分页获取管理员
    /// </summary>
    /// <param name="pagination"></param>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("getIndex")]
    public async Task<SugarPagedList<SysUserPageItem>> GetIndex([FromQuery] BasePageInput pagination,[FromBody]SysUserPageInput input)
    {
        return await _adminService.GetPageList(pagination, input);
    }
    /// <summary>
    /// 根据id获取Admin
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet("getDetail")]
    public async Task<SysUserDetailOutput> GetDetail([FromQuery] int id)
    {
        return await _adminService.Get(id);
    }
    /// <summary>
    /// 新增Admin
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("add")]
    public async Task Add(AddSysUserInput input)
    {
        await _adminService.Add(input);
    }
    /// <summary>
    /// 删除Admin
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    [HttpDelete("delete")]
    public async Task Delete([FromQuery] string ids)
    {
        await _adminService.Delete(ids.SplitToIntList().ToList());
    }
    /// <summary>
    /// 编辑Admin
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("edit")]
    public async Task Edit(EditSysUserInput input)
    {
        await _adminService.Edit(input);
    }


    
}
